<template>
  <div ref="chart" style="width: 100%; height: 400px;"></div>
</template>

<script>
import echarts from 'echarts'

export default {
  name: 'CustomerCharts',
  props: ['spreadData'],
  data () {
    return {
      customerDataList: [
        { value: 1048, name: 'Java' },
        { value: 735, name: 'Python' },
        { value: 580, name: '大数据' },
        { value: 484, name: 'C++' },
        { value: 300, name: 'C#' }
      ]
    }
  },
  mounted () {
    this.renderChart()
  },
  methods: {
    renderChart () {
      const chart = echarts.init(this.$refs.chart)
      chart.setOption({
        title: {
          top: '20',
          show: true,
          text: '客户分布统计',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          bottom: '10%',
          left: 'center'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            padAngle: 5,
            itemStyle: {
              borderRadius: 10
            },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 40,
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: this.spreadData
          }
        ]
      })
    }
  }
}
</script>
